package com.gitee.wsl.compose.chart.xy.bar.model

import com.gitee.wsl.compose.chart.xy.model.PointEntry


typealias BarEntry<X, Y> = PointEntry<X,BarPosition<Y>>

fun <X> PointEntry<X,Float>.toBarEntry() = BarEntry(x,0f,y)

@JvmName("toBarEntryDouble")
fun <X> PointEntry<X,Double>.toBarEntry() = BarEntry(x,0.0,y)

@JvmName("toBarEntryInt")
fun <X> PointEntry<X,Int>.toBarEntry() = BarEntry(x,0,y)

@JvmName("toBarEntryLong")
fun <X> PointEntry<X,Long>.toBarEntry() = BarEntry(x,0L,y)

/**
 * An interface that defines a data element to be plotted on a Bar chart.
 * @param X The type of the x-axis values
 * @param Y The type of the y-axis values
 */
// interface BarEntry<X, Y> {
//    /**
//     * X-axis value at which the bar should be plotted
//     */
//     val x: X
//
//    /**
//     * The y-axis value for the bar.
//     */
//     val y: BarPosition<Y>
//}

/**
 * Convenience function for creating a VerticalBarPosition.
 */
// fun <Y> BarPlotEntry(yMin: Y, yMax: Y): BarPosition<Y> =
//    DefaultBarPosition(yMin, yMax)

/**
 * Convenience function for creating a VerticalBarPlotEntry.
 */
 fun <X, Y> BarEntry(x: X, yMin: Y, yMax: Y): BarEntry<X, Y> =
    DefaultBarEntry(x, BarPosition(yMin, yMax))


fun <X, Y> BarEntry(x: X, entry:BarPosition<Y>): BarEntry<X, Y> =
    DefaultBarEntry(x,entry )

/**
 * Default implementation of a BarChartEntry.
 * @param X The type of the x-axis values
 * @param Y The type of the y-axis values
 */
 internal data class DefaultBarEntry<X, Y>(
     override val x: X,
     override val y: BarPosition<Y>
) : BarEntry<X, Y>
